<?php getView('modules/header',array('header' => $header)); ?>

<?php getView('modules/admin-menu'); ?>

<div id="content-wrapper" class="container-fluid">
	<div class="row">
		<?php getView('modules/admin-sidebar', array('menu_active',$menu_active)); ?>
		<div id="admin-content">
			<div class="col-xs-12">
				<!-- Show Alert -->
				<?php 
					if(isset($alert))
						getView('modules/admin-alert', $alert);
				?> 
				<div class="below-alert"></div>
				<div class="row">
					<div class="col-xs-12">
						<a href="post_new" class="btn btn-primary mgb15">Add New</a>
						<?php echo $content; ?>
					</div>
				</div>
				<?php getView('modules/footer'); ?>
			</div>
		</div>
	</div>
</div>
<script>
	$('a.move-trash').click(function(event) {
		/* Act on the event */
		event.preventDefault();
		var post_id = $(this).data('id');
		var flag = false;
		if(flag) return false; 
			flag = true;
		$.post('post/moveTrash', {post_id: post_id}, function(json) {
			if(json.status == 0){
				adminAlert(json.message, 3000, 'error');
			}else{
				window.location.reload();
			}
			flag = false;
		}, 'json');
	});

	$('a.move-publish').click(function(event) {
		/* Act on the event */
		event.preventDefault();
		var post_id = $(this).data('id');
		var flag = false;
		if(flag) return false; flag = true;
		$.post('post/movePublish', {post_id: post_id}, function(json) {
			if(json.status == 0){
				adminAlert(json.message, 3000, 'error');
			}else{
				window.location.reload();
			}
			flag = false;
		},'json');
		
	});

	$('a.delete-post').click(function(event) {
		/* Act on the event */
		event.preventDefault();
		var cf = confirm('Are you sure you wish to delete this post?');
		if(cf == true){
			var post_id = $(this).data('id');
			var flag = false;
			if(flag) return false; flag = true;
			$.post('post/deletePost', {post_id: post_id}, function(json) {
				if(json.status == 0){
					adminAlert(json.message, 3000, 'error');
				}else{
					window.location.href = 'post';
				}
				flag = true;
			},'json');
		}
		else{
			return false;
		}
		
	});
</script>
</body>
</html>